﻿// (c) Copyright Michael Antonio.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;
using MichMan.Utilities.Requests;

namespace Subsonic.ViewModels
{
    public class PivotViewModel : BaseViewModel
    {
        public PivotViewModel()
        {
            Pivots = new ObservableCollection<BasePivotItemViewModel>();
        }

        public sealed override IRequest Load()
        {
            if (Pivots.Count != 0)
            {
                return null;
            }

            IRequest request = LoadPivots();

            if (request != null)
            {
                request.RunRequestCompleted += (s, e) => NotifyLoaded(e);
            }
            else
            {
                NotifyLoaded(null);
            }

            return request;
        }

        // Load Pivots collection.
        public virtual IRequest LoadPivots()
        {
            return null;
        }

        public ObservableCollection<BasePivotItemViewModel> Pivots { get; private set; }
    }
}
